<template>
  <div class="board">
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column label="小区名称" prop="communityname">
        <template slot-scope="scope">
          <span>{{ scope.row.communityname }}</span>
        </template>
      </el-table-column>
      <el-table-column label="单元名称">
        <template slot-scope="scope">
          <span>{{ scope.row.unitname }}</span>
        </template>
      </el-table-column>
      <el-table-column label="栋数">
        <template slot-scope="scope">
          <span>{{ scope.row.unitnum }}</span>
        </template>
      </el-table-column>
      <el-table-column label="建设时间">
        <template slot-scope="scope">
          <span>{{ scope.row.createtime }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态">
        <template slot-scope="scope">
          <span v-if="scope.row.unitstatus == 1">已建成</span>
          <span v-else>未建成</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import axios from "axios";
import Cookies from "js-cookie";
import Pagination from "@/components/Pagination";
export default {
  data() {
    return {
      fileList: [],
      queryInfo: [],
      srcList: [],
     
      tableData: [],
      sendInfo: {
        page: 1,
        limit: 20,
        sort: "add_time",
        order: "desc"
      },
      Token: "",
      componentTotal: 0,
      dialogFormVisible: false,
      onceInfo: {
        communityname: "",
        unitname: "",
        createDt: "",
        value: "",
        currPage: 1,
        pageNum: 10
      },
      token:
        "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjEyLCJ1c2VybmFtZSI6ImFkbWluIiwiZW1haWwiOiJ3ZSIsImhlYWQiOiIyMDI0MDMwODE5Mzc1Nzg3MTE4OTAuanBnIiwidHlwZSI6IjEiLCJpYXQiOjE3MTE0MTQwNTgsImV4cCI6MTcxMTUwMDQ1OH0.2xNMp69GtTbiIq_-hfV7GYH0WO6gyEanoXWXefHzmqE"
    };
  },
  methods: {
    async getTableData(id) {
      console.log(id);
      const { data: res } = await axios.get(
        `http://community.byesame.com/house/getDetailId?id=${id}&token=${this.Token}`,
        {
          params: this.sendInfo
        }
      );
      console.log(6);
      console.log(res);
      console.log(this.tableData);
      this.tableData.push(res[0]);
      // if (res.code != 200) return this.$message.error("查询失败");
    //   this.tableData = res.data;
    //   this.componentTotal = res.total;
      console.log(this.tableData);
    },
    created() {
      this.getTableData();
    }
  },
  mounted() {
    this.Token = Cookies.get("Admin-Token");
    this.id = this.$route.query.id;
    console.log(this.id);
    this.getTableData(this.id);
  },
  components: {
    Pagination
  },
  computed: {
    headers() {
      return {
        //上传图片时，携带请求头
        "X-Litemall-Admin-Token": this.Token
      };
    }
  }
};
</script>

<style lang="scss" scoped>
.board {
  padding: 20px;
}
.vatimg {
  width: 145px;
  height: 145px;
  display: block;
}
</style>